package com.wg.user.util;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Random;
import java.util.UUID;

/**
 * 字符操作
 */
public class StringUtil extends StringUtils {

    private static final Logger logger = LoggerFactory.getLogger(StringUtil.class);

    private static char[] hexDigits = { '0', '1', '2', '3', '4', '5', '6', '7',
            '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };

    public static final String DEFAULT_BOUND_SYMBOL = ","; // 平台默认连接符（1,2,3）

    public static final String DATA_STATISTICS_HASH_KEY_COMBINER = "&&"; // 统计数据REIDS KEY连接符

    /**
     * 字符串转换成double 数
     *
     * @param strDouble
     * @return
     */
    public static double toDouble(String strDouble) {
        if (strDouble == null || strDouble.trim().length() == 0) {
            return 0d;
        }

        try {
            return Double.parseDouble(strDouble);
        } catch (Exception e) {
            return 0d;
        }
    }

    /**
     * 字符串转换成int 数
     *
     * @param strInt
     * @return
     */
    public static int toInt(String strInt) {
        if (strInt == null || strInt.trim().length() == 0) {
            return 0;
        }

        try {
            return Integer.parseInt(strInt);
        } catch (Exception e) {
            return 0;
        }
    }


}
